<include file="public@header" />
<style>
	/*table{ border:1px solid #000; width:80%; font-size:1rem; margin-bottom:20px}
	td{border:1px solid #000; padding:0 5px; height:2rem; text-align:center}*/

	.content_nav .check_info{flex:1; display:flex;flex-direction: column;align-items: center;justify-content: center;}
	.form-horizontal .control-group1 {
		float: left;
		width: 15%;
		margin-bottom: 20px;
	}
	.form-horizontal .control-label {width:80px;}
	.form-horizontal .controls {margin-left:90px;}

</style>
</head>

    <div class="wrap js-check-wrap" style="padding-top: -10px !important;">
		<ul class="nav nav-tabs">
			<li class="active"><a href="">申请迁墓</a></li>
		</ul>

        <div class="form-horizontal">
        <fieldset>
            <!--改版画面-->
            <div class="div_title"><span>客户概览</span></div>
            <div class="control-group1-p div_content">
                <div class="control-group1">
                    <label class="control-label">客户姓名</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.buyer_name}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">持证类型</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{:cart_type('cart',$result.cart_type)}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">证件号码</label>
                    <div class="controls">
                        <input type="text" class="form-control" style="width:150px;" value="{$result.customer_account}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">联系电话</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.buyer_phone}" disabled>
                    </div>
                </div>
                <div class="control-group1" style="width:40%;">
                    <label class="control-label">联系地址</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.customer_address}" style="width:80%;" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">合同编号</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.contract_sn}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">购买日期</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.gm_start_time}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">打证日期</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.dz_start_time}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">保修期</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.end_bxq_time}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">当前状态</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.col_status_name}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">维护期</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.end_whq_time}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">墓位编号</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.tomb_num}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">具体位置</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.tomb_region}{$result.tomb_address}" disabled>

                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">墓穴规制</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.tomb_regulation_name}" disabled>
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">收敛形式</label>
                    <div class="controls">
                        <input type="text" class="form-control" value="{$result.convergence}" disabled>
                    </div>
                </div>
            </div>
        </fieldset>
        <fieldset>
            <!---tab页-->
            <ul class="nav_tabs" style="margin-left: 0;margin-right: 0;">
                <li class="active"><a href="javascript:">迁墓登记</a></li>
                <li><a href="javascript:">审核意见</a></li>
            </ul>
            <div class="control-group1-p nav_content" id="upload_file" style="margin-left: 0;margin-right: 0;">
            	<div class="content_nav">
                    <form action="{:url('Move/move_post')}" id="move_form" >
                	<div class="p_title">
                        <span class="span_title">迁出逝者</span>
                    </div>

                    <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;padding-bottom:15px;margin:0 20px;overflow:hidden; overflow-x:auto;">
                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr>
                                <th width="2%">
                                   <label>
                                        <input type="checkbox" class="js-check-all" style="align-content: center" data-direction="x" data-checklist="js-check-x">
                                    </label>
                                </th>
                                <th width="12%">逝者姓名</th>
                                <th width="10%">性别</th>
                                <th width="20%">生卒日期</th>
                                <th width="12%">落葬时间</th>
                                <th width="12%">收敛形式</th>
                                <th  width="12%">落葬类别</th>
                                <th width="10%">与持证人关系</th>
                                <th width="10%">火化证明</th>
                            </tr>
                        </thead>
                        <tbody>
                            <foreach name="deceased_list" item="vo">
                            <tr>
                                <td style="text-align: center">
                                    <if condition="$vo.move_status eq '1' || empty($vo.move_status)">
                                    <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" checked="checked"
                                                  value="{$vo.deceased_id}" title="ID:{$vo.deceased_id}">
                                    </if>
                                </td>
                                <td>
                                    <input type="hidden" class="form-control" name="order_id" value="{$result.order_id}">
                                    <input type="hidden" class="form-control" name="customer_id" value="{$result.customer_id}">
                                    <input type="hidden" class="form-control" name="tomb_id" value="{$result.tomb_id}">
                                    <input type="hidden" class="form-control" name="tomb_num" value="{$result.tomb_num}">

                                    {$vo['deceased_name']|default=''}
                                </td>
                                <td>
                                    <if condition="'1' eq $vo.gender">
                                        男
                                    </if>
                                    <if condition="'2' eq $vo.gender">
                                        女
                                    </if>
                                </select>
                                </td>
                                <td>
                                    {$vo['date_birth']|date='Y-m-d'} ~ {$vo['date_death']|date='Y-m-d'}
                                </td>
                                <td>
                                    {$vo['date_death']|date='Y-m-d'}
                                </td>
                                <td>
                                    <if condition="'1' eq $vo.convergence_type">
                                        骨灰
                                    </if>
                                    <if condition="'2' eq $vo.convergence_type">
                                        骨殖
                                    </if>
                                </td>
                                <td>
                                    <if condition="'1' eq $vo.type">
                                        首位安葬
                                    </if>
                                    <if condition="'2' eq $vo.type">
                                        合葬
                                    </if>
                                </td>
                                <td>{$vo.relationship_users|default=''}</td>
                                <td>
                                    <php>$img_url=cmf_get_image_preview_url(isset($vo['cremation_certificate'])?$vo['cremation_certificate']:'');</php>
                                    <img height="50" src="{$img_url}" style="height:36px;width: 36px;"
                                         onclick="parent.imagePreviewDialog(this.src);">
                                    <a href="{$img_url}" download = '导出' class="btn btn-primary">导出</a>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                  </div>

                  <div class="p_title">
                        <span class="span_title">迁墓资料</span>
                    </div>
                    <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;padding-bottom:15px;margin:0 20px;overflow:hidden; overflow-x:auto;">

                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr>
                                <th>持证人身份证</th>
                                <th>墓穴使用合同</th>
                                <th>墓穴安葬证</th>
                                <th>购买凭证</th>
                                <th>迁墓合同</th>
                                <th ></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                            	<td>
                                    <php>$img_urls=cmf_get_image_preview_url(isset($service['url_idcard'])?$service['url_idcard']:'');</php>
                                    <input type="hidden" name="url_idcard" id="url_idcard" value="{$service['url_idcard']|default=''}">
                                    <a href="javascript:;"  class="upload_file"  onclick="gpyUploadOneImage('持证人身份证', '#url_idcard','{$result.tomb_num}');">
                                        <h5 class="btn btn-primary">拍照上传</h5>
                                    </a>
                                    <img height="50" src="{$img_urls}" class="preview" id="url_idcard-preview" onclick="parent.imagePreviewDialog(this.src);"/>
                                </td>
                                <td>
                                    <php>$img_urls1=cmf_get_image_preview_url(isset($service['url_contract'])?$service['url_contract']:'');</php>
                                    <input type="hidden" name="url_contract" id="url_contract" value="{$service['url_contract']|default=''}">
                                    <a href="javascript:;" class="upload_file"   onclick="gpyUploadOneImage('墓穴使用合同', '#url_contract','{$result.tomb_num}');">
                                        <h5 class="btn btn-primary">拍照上传</h5>
                                    </a>
                                    <img height="50" src="{$img_urls1}" class="preview" id="url_contract-preview" onclick="parent.imagePreviewDialog(this.src);"/>
                                </td>
                                <td>
                                    <php>$img_urls2=cmf_get_image_preview_url(isset($service['url_burial'])?$service['url_burial']:'');</php>
                                    <input type="hidden" name="url_burial" id="url_burial" value="{$service['url_burial']|default=''}">
                                    <a href="javascript:;" class="upload_file" onclick="gpyUploadOneImage('墓穴安葬证', '#url_burial','{$result.tomb_num}');">
                                        <h5 class="btn btn-primary">拍照上传</h5>
                                    </a>
                                    <img height="50" src="{$img_urls2}" class="preview" id="url_burial-preview" onclick="parent.imagePreviewDialog(this.src);"/>
                                </td>
                                <td>
                                    <php>$img_urls3=cmf_get_image_preview_url(isset($service['url_buy'])?$service['url_buy']:'');</php>
                                    <input type="hidden" name="url_buy" id="url_buy" value="{$service['url_buy']|default=''}">
                                    <a href="javascript:;" class="upload_file" onclick="gpyUploadOneImage('购买凭证', '#url_buy','{$result.tomb_num}');">
                                        <h5 class="btn btn-primary">拍照上传</h5>
                                    </a>
                                    <img height="50" src="{$img_urls3}" class="preview" id="url_buy-preview" onclick="parent.imagePreviewDialog(this.src);"/>

                                </td>
                                <td>
                                    <php>$img_urls4=cmf_get_image_preview_url(isset($service['url_move'])?$service['url_move']:'');</php>
                                    <input type="hidden" name="url_move" id="url_move" value="{$service['url_move']|default=''}">
                                    <a href="javascript:;" class="upload_file"  onclick="gpyUploadOneImage('迁墓合同', '#url_move','{$result.tomb_num}');">
                                        <h5 class="btn btn-primary">拍照上传</h5>
                                    </a>
                                    <img height="50" src="{$img_urls4}" class="preview" id="url_move-preview" onclick="parent.imagePreviewDialog(this.src);"/>
                                </td>
                                <td>
                                	<div class="btn btn-warning" id="print_check-btn" data-k="1" >打印迁墓合同</div>
                                </td>
                            </tr>
                        </tbody>
                    </table>

                  </div>
                  <div class="p_title">
                        <span class="span_title">迁墓人信息</span>
                    </div>
                    <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;padding-bottom:15px;margin:0 20px;overflow:hidden; overflow-x:auto;">

                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr>
                                <th  width="10%">持证人</th>
                                <th width="6%">性别</th>
                                <th width="10%">手机号码</th>
                                <th width="8%"></th>
                                <th width="15%">联系地址</th>
                                <th width="10%">迁墓原因</th>
                                <th width="10%">预约迁墓时间</th>
                                <th width="10%">原碑处置方案</th>
                                <th width="8%">迁墓费</th>
                                <th width="8%">接待人</th>
                                <th width="10%">经办人</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                            	<td><input type="text" class="form-control" value="{$service['buyer_name']|default=''}" name="buyer_name" id="buyer_name" style="width: 120px;"></td>
                                <td>
                                    <select name="buyer_sex" class="form-control" >
                                        <if condition="isset($service['buyer_sex']) ">
                                            <option value='1'<if condition="'1' eq $service['buyer_sex']">selected</if>>男</option>
                                            <option value="2" <if condition="'2' eq $service['buyer_sex']">selected</if>>女</option>
                                        <else>
                                            <option value='1'>男</option>
                                            <option value="2">女</option>
                                        </else>
                                        </if>

                                    </select>
                                </td>
                                <input type="hidden" class="form-control" name="service_id" value="{$service.id|default=''}">

                                <td><input type="text" class="form-control" name="buyer_phone" id="buyer_phone" value="{$service['buyer_phone']|default=''}" style="width: 120px;" required></td>
                                <td>
                                    <input type="checkbox" name="is_send" checked style="width: 20px !important;" value="1">短信通知
                                </td>
                                <td><input type="text" class="form-control"  required name="buyer_address" id="buyer_address" value="{$service['buyer_address']|default=''}"></td>
                                <td>
                                    <if condition="isset($service['move_reason'])">
                                        <select class="form-control" name="move_reason">
                                            <option value='更换墓位'<if condition="'更换墓位' eq $service['move_reason']">selected</if>>更换墓位</option>
                                            <option value="回老家"<if condition="'回老家' eq $service['move_reason']">selected</if>>回老家</option>
                                            <option value="更换墓园"<if condition="'更换墓园' eq $service['move_reason']">selected</if>>更换墓园</option>
                                            <option value="其他"<if condition="'其他' eq $service['move_reason']">selected</if>>其他</option>
                                        </select>

                                    <else>
                                        <select class="form-control" name="move_reason">
                                            <option value="更换墓位">更换墓位</option>
                                            <option value="回老家">回老家</option>
                                            <option value="更换墓园">更换墓园</option>
                                            <option value="其他">其他</option>
                                        </select>
                                    </else>
                                    </if>

                                </td>
                                <td>
                                    <input type="text" class="form-control js-datetime"  autocomplete="off" style="width: 150px;" name="move_time" id="move_time" value="{$service['move_time']|default=''}" required >
                                </td>
								<td>
                                    <if condition="isset($service['tombstone_plan'])">
                                        <select class="form-control" name="tombstone_plan">
                                            <option value="破碎"<if condition="'破碎' eq $service['tombstone_plan']">selected</if>>破碎</option>
                                            <option value="带回"<if condition="'带回' eq $service['tombstone_plan']">selected</if>>带回</option>
                                            <option value="放弃"<if condition="'放弃' eq $service['tombstone_plan']">selected</if>>放弃</option>
                                        </select>
                                    <else>
                                        <select class="form-control" name="tombstone_plan">
                                            <option value="破碎">破碎</option>
                                            <option value="带回">带回</option>
                                            <option value="放弃">放弃</option>
                                        </select>
                                    </else>
                                    </if>

                                </td>
                                 <td>
                                     <input type="text" class="form-control" style="width: 80px;"  value="{$move_cost['move_cost']}" disabled>
                                     <input type="hidden" class="form-control" style="width: 80px;" name="move_money" value="{$move_cost['move_cost']}" >
                                 </td>
                                <td>
                                    <if condition="isset($service['receptionist'])">
                                        <select name="receptionist" class="form-control">
                                            <foreach name="userlist" item="vou">
                                                <option value="{$vou.id}"<if condition="$vou['id'] eq $service['receptionist']">selected</if>>{$vou.department_name}-{$vou.user_nickname}</option>
                                            </foreach>
                                        </select>
                                    <else>
                                        <select name="receptionist" class="form-control">
                                            <foreach name="userlist" item="vou">
                                                <option value="{$vou.id}">{$vou.department_name}-{$vou.user_nickname}</option>
                                            </foreach>
                                        </select>
                                    </else>
                                    </if>

                                </td>
                                <td>
                                    <input type="text" class="form-control" style="width: 120px;"  value="{:cmf_get_admin_name()}" disabled>
                                    <input type="hidden" class="form-control" style="width: 120px;" name="handle_name" value="{:cmf_get_admin_name()}">
                                    <input type="hidden" class="form-control" style="width: 120px;" name="handle_id" value="{$handle_id|default=''}" >
                                    <input type="hidden" class="form-control" value="{$result.tomb_region}{$result.tomb_address}" name="tomb_address">
                                </td>
                            </tr>
                        </tbody>
                    </table>

                  </div>
                  <div class="form-actions">
                        <input type="hidden" name="submit_status" id="submit_status" value="1">
                        <div class="btn btn-primary" id="check-btn-save" >保存</div>
                        <div class="btn btn-primary" id="check-btn-submit" >提交审核</div>
                  </div>
                </form>
                </div>
                <div class="content_nav feature"  >
                    <if condition="isset($approvialinfo['approval_status'])">
                        <if condition="$approvialinfo['approval_status'] == '1'">
                            <div class="check_info">
                                <P style="color:#0b7ebf">您的迁墓申请已于<php >echo date('Y-m-d H:m', $approvialinfo['apply_time'])</php>成功提交</P>
                                <P>申请处理中，请耐心等待！</P>
                            </div>
                        </if>

                        <if condition="$approvialinfo['approval_status'] == '2'">
                            <div class="check_info">
                                <img src="/__TMPL__Public/assets/images/agree.jpg" style="max-width:100px;"/>
                                <P style="color:#4ABD41;font-size:20px;">您的迁墓申请已申请通过</P>
                                <P style="color:#999999;"><php >echo date('Y-m-d H:m', $approvialinfo['approval_time'])</php></P>
                                <div>迁墓费{$move_cost['move_cost']}元</div>
                                <div class="btn btn-warning" id="print_check-btn11" data-k="1" data-contract_file="{$contract_file}" >打印迁墓合同</div>
                            </div>
                        </if>
                        <if condition="$approvialinfo['approval_status'] == '3'">
                            <div class="check_info">
                                <img src="__TMPL__/Public/assets/images/warn.jpg" style="max-width:100px;"/>
                                <P style="color:#EE860A;font-size:20px;">您的迁墓申请未申请通过</P>
                                <P style="color:#999999;"><php >echo date('Y-m-d H:m', $approvialinfo['approval_time'])</php></P>
                                <div style="padding:5px;max-width:200px;border:1px solid #f2f2f2;">未通过原因： {$approvialinfo['approval_desc']}</div>
                                <div class="btn btn-primary" id="check-btn" style="margin-top:10px;">请重新填写迁墓申请内容</div>
                            </div>
                        </if>
                        <else>
                        </else>
                    </if>
                </div>
            </div>
        </fieldset>
        </div>
    </div>
    <iframe id="printf" src="" width="0" height="0" frameborder="0"></iframe>
	<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
    <script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<link href="__STATIC__/js/bootstrap-table/dist/bootstrap-table.css" rel="stylesheet"/>
	<script type="text/javascript">
        //切换显示
        $(document).on('click','.nav_tabs li',function(){
            $(this).addClass('active').siblings().removeClass('active');
            var index = $(".nav_tabs li").index(this);
            billtype = index;
            console.log(index);
            $('.content_nav').eq(index).removeClass("feature").siblings().addClass("feature");
        })
	// 保存表单
    $('#check-btn-save').click(function () {
        var url_idcard = $("#url_idcard").val();
        if(url_idcard == null || url_idcard ==""){
            alert("请上传持证人身份证！");
            return;
        }
        var url_contract = $("#url_contract").val();
        if(url_contract == null || url_contract ==""){
            alert("请上传墓穴使用合同！");
            return;
        }
        var url_burial = $("#url_burial").val();
        if(url_burial == null || url_burial ==""){
            alert("请上传墓穴安葬证！");
            return;
        }
        var url_buy = $("#url_buy").val();
        if(url_buy == null || url_buy ==""){
            alert("请上传购买凭证！");
            return;
        }
        var url_move = $("#url_move").val();
        if(url_move == null || url_move ==""){
            alert("请上传迁墓合同！");
            return;
        }

        var buyer_name = $("#buyer_name").val();
        if(buyer_name == null || buyer_name ==""){
            alert("请输入持证人姓名！");
            return;
        }
        var buyer_phone = $("#buyer_phone").val();
        if(buyer_phone == null || buyer_phone ==""){
            alert("请输入手机号码！");
            return;
        }
        var buyer_address = $("#buyer_address").val();
        if(buyer_address == null || buyer_address ==""){
            alert("请输入联系地址！");
            return;
        }
        var move_time = $("#move_time").val();
        if(move_time == null || move_time ==""){
            alert("请选择预约迁墓时间！");
            return;
        }

        $("#submit_status").val("1");
        $.post($("#move_form").attr('action'), $("#move_form").serialize(), function(result){
            console.log(result)
            if(result.code == 1){
                layer.alert('保存成功。', {icon: 1, yes: function (index) {
                        layer.close(index);
                        window.location.href = result.url;
                    }})
            } else {
                layer.msg(result.msg);
            }
        }, 'json');
    })
    // 提交表单
    $('#check-btn-submit').click(function () {
        var url_idcard = $("#url_idcard").val();
        if(url_idcard == null || url_idcard ==""){
            alert("请上传持证人身份证！");
            return;
        }
        var url_contract = $("#url_contract").val();
        if(url_contract == null || url_contract ==""){
            alert("请上传墓穴使用合同！");
            return;
        }
        var url_burial = $("#url_burial").val();
        if(url_burial == null || url_burial ==""){
            alert("请上传墓穴安葬证！");
            return;
        }
        var url_buy = $("#url_buy").val();
        if(url_buy == null || url_buy ==""){
            alert("请上传购买凭证！");
            return;
        }
        var url_move = $("#url_move").val();
        if(url_move == null || url_move ==""){
            alert("请上传迁墓合同！");
            return;
        }

        var buyer_name = $("#buyer_name").val();
        if(buyer_name == null || buyer_name ==""){
            alert("请输入持证人姓名！");
            return;
        }
        var buyer_phone = $("#buyer_phone").val();
        if(buyer_phone == null || buyer_phone ==""){
            alert("请输入手机号码！");
            return;
        }
        var buyer_address = $("#buyer_address").val();
        if(buyer_address == null || buyer_address ==""){
            alert("请输入联系地址！");
            return;
        }
        var move_time = $("#move_time").val();
        if(move_time == null || move_time ==""){
            alert("请选择预约迁墓时间！");
            return;
        }
        $("#submit_status").val("2");

        $.post($("#move_form").attr('action'), $("#move_form").serialize(), function(result){
            console.log(result)
            if(result.code == 1){
                layer.alert('保存成功。', {icon: 1, yes: function (index) {
                        layer.close(index);
                        window.location.href = result.url;
                    }})
            } else {
                layer.msg(result.msg);
            }
        }, 'json');
    })

    //打印迁墓合同
        $('#print_check-btn').on('click',function () {
            var k = $(this).data('k');
            if (k==1){
                    var title = $(this).text();
                    var url = 'https://view.officeapps.live.com/op/view.aspx?src=http://gd.zhmyxt.com/document/contract/迁墓协议（一式两份）.doc';
                    layer.open({
                        type: 2,
                        icon: 4,
                        title: title,
                        anim: 2,
                        area: ['50%','90%'],
                        content: url
                    });
            } else {
                $.post("{:url('Stamp/print_cert')}",{'type':3},function(result){
                    if(result.status==1){
                        var f = document.getElementById('printf');
                        f.contentDocument.write(result.html);
                        f.contentDocument.close();
                        f.contentWindow.print();
                        return false;
                    }
                },'json')
            }
        })
        $("#print_check-btn11").click(function () {
            var file = $(this).data('contract_file');
            console.log(file)
            if (file){
                var url = file;
                layer.open({
                    type: 2,
                    icon: 4,
                    title: '迁墓合同',
                    anim: 2,
                    area: ['50%','90%'],
                    content: url
                });
            }

        })
    </script>

</body>
</html>